<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html >
<html lang="en">
<head>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/bootstrap.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/font-awesome.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/ace-fonts.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/ace.min.css"
	id="main-ace-style" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/ace-skins.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/ace-rtl.min.css" />
<script
	src="${pageContext.request.contextPath}/static/assets/js/ace-extra.min.js"></script>
</head>

<body class="no-skin">
	<!-- /section:basics/sidebar -->
	<div class="main-content">
		<!-- #section:basics/content.breadcrumbs -->
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try {
					ace.settings.check('breadcrumbs', 'fixed')
				} catch (e) {
				}
			</script>

			<ul class="breadcrumb">
				<li><i class="ace-icon fa fa-home home-icon"></i> <a href="#">Home</a>
				</li>

				<li><a href="#">Tables</a></li>
				<li class="active">Simple &amp; Dynamic</li>
			</ul>
			<!-- /.breadcrumb -->

			<!-- #section:basics/content.searchbox -->
			<div class="nav-search" id="nav-search">
				<form class="form-search">
					<span class="input-icon"> <input type="text"
						placeholder="Search ..." class="nav-search-input"
						id="nav-search-input" autocomplete="off" /> <i
						class="ace-icon fa fa-search nav-search-icon"></i>
					</span>
				</form>
			</div>
			<!-- /.nav-search -->

			<!-- /section:basics/content.searchbox -->
		</div>

		<!-- /section:basics/content.breadcrumbs -->
		<div class="page-content">
			<!-- #section:settings.box -->

			<!-- /.ace-settings-container -->

			<!-- /section:settings.box -->
			<div class="page-content-area">
				<div class="page-header">
					<div class="testDescription">
						本次考试的参考时长为:&nbsp;&nbsp;<span id="testTimer"></span>&nbsp;&nbsp;&nbsp;&nbsp;总分为:&nbsp;&nbsp;<span
							id="testScore">${sub.totalScore }</span>&nbsp;&nbsp;分
					</div>
				</div>
				<!-- /.page-header -->



				<div class="row">
					<div class="col-xs-12">
						<!-- PAGE CONTENT BEGINS -->
						<div class="row">
							<form id="test-form"
								action="${pageContext.request.contextPath}/teacher/assignment/${examUser.userId}"
								method="post">
								<input type="hidden" name="userId" value="${examUser.userId }" />
								<input type="hidden" name="subId" value="${sub.subId }" />
								<%
									int i = 1;
								%>
								<c:forEach items="${testListMap[1] }" var="radio">
									<label><%=i%>、</label>
									<span class="content">${radio.content }</span>(<span
										class="test-type">${radio.examTestType.testType }</span>,<span
										class="test-type-score">${radio.examTestType.testTypeScore }</span>分)<br />
									<label><input type="radio" name="test_${radio.id }"
										value="A" />&nbsp;&nbsp;A、</label>
									<span class="choose-a">${radio.chooseA }</span>
									<br />
									<label><input type="radio" name="test_${radio.id }"
										value="B" />&nbsp;&nbsp;B、</label>
									<span class="choose-b">${radio.chooseB }</span>
									<br />
									<label><input type="radio" name="test_${radio.id }"
										value="C" />&nbsp;&nbsp;C、</label>
									<span class="choose-c">${radio.chooseC }</span>
									<br />
									<label><input type="radio" name="test_${radio.id }"
										value="D" />&nbsp;&nbsp;D、</label>
									<span class="choose-d">${radio.chooseD }</span>
									<br />
									<%
										i++;
									%>
								</c:forEach>
								<c:forEach items="${testListMap[2] }" var="radio">
									<label><%=i%>、</label>
									<span class="content">${radio.content }</span>(<span
										class="test-type">${radio.examTestType.testType }</span>,<span
										class="test-type-score">${radio.examTestType.testTypeScore }</span>分)<br />
									<label><input type="checkbox" name="test_${radio.id }"
										value="A">&nbsp;&nbsp;A、</label>
									<span class="choose-a">${radio.chooseA }</span>
									<br />
									<label><input type="checkbox" name="test_${radio.id }"
										value="B">&nbsp;&nbsp;B、</label>
									<span class="choose-b">${radio.chooseB }</span>
									<br />
									<label><input type="checkbox" name="test_${radio.id }"
										value="C">&nbsp;&nbsp;C、</label>
									<span class="choose-c">${radio.chooseC }</span>
									<br />
									<label><input type="checkbox" name="test_${radio.id }"
										value="D">&nbsp;&nbsp;D、</label>
									<span class="choose-d">${radio.chooseD }</span>
									<br />
									<%
										i++;
									%>
								</c:forEach>
							</form>
						</div>
						<!-- /.row -->
						<button id="submitTestBtn" type="button" class="btn btn-primary">提交</button>
						<div class="hr hr-18 dotted hr-double"></div>
					</div>
					<!-- /.col -->
				</div>
				<!-- /.row -->
			</div>
		</div>
	</div>


	<script type="text/javascript">
		window.jQuery
				|| document
						.write("<script src='${pageContext.request.contextPath}/static/assets/js/jquery.min.js'>"
								+ "<"+"/script>");
	</script>

	<script type="text/javascript">
		if ('ontouchstart' in document.documentElement)
			document
					.write("<script src='${pageContext.request.contextPath}/static/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"/script>");
	</script>

	<script
		src="${pageContext.request.contextPath}/static/assets/js/bootstrap.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/lib/bootstrap-switch.js"></script>
	<!-- page specific plugin scripts -->
	<script
		src="${pageContext.request.contextPath}/static/assets/js/jquery.dataTables.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/assets/js/jquery.dataTables.bootstrap.js"></script>

	<!-- ace scripts -->
	<script
		src="${pageContext.request.contextPath}/static/assets/js/ace-elements.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/assets/js/ace.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/lib/jquery.jqprint-0.3.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/lib/jquery-migrate-1.1.0.js"></script>

	<script type="text/javascript">
		$(function() {
			function initTimer() {
				var resultTime = 0;
				var testTotalTime = Number('${sub.totalTime}');
				return testTotalTime * 60;
			}
			function statrtTimer(totalSecend) {
				$('#testTimer').text(formatTime(totalSecend));
				var timer = setInterval(function() {
					totalSecend--;
					if (totalSecend >= 0) {
						$('#testTimer').text(formatTime(totalSecend));
					} else {
						alert('考试结束!');
						clearInterval(timer);
						assignment();
					}
				}, 1000);
			}
			function formatTime(totalSecend) {
				var hour = Math.floor(totalSecend / 3600);
				var min = Math.floor((totalSecend % 3600) / 60);
				var secend = Math.floor(totalSecend % 60);
				hour = formatTimeNumber(hour);
				min = formatTimeNumber(min);
				secend = formatTimeNumber(secend);
				return hour + ':' + min + ':' + secend;
			}

			function formatTimeNumber(timeNumber) {
				if (timeNumber < 10) {
					return "0" + timeNumber;
				} else {
					return timeNumber;
				}
			}

			function assignment() {
				$('#test-form').submit();
			}

			$('#submitTestBtn').click(function() {
				if (confirm("是否确认提交？")) {
					assignment();
				}
			});
			statrtTimer(initTimer());
		})
	</script>


</body>
</html>
